﻿Public Class clsControlPoint

    Public Function insert(en As entityControlPoint) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer
        sql &= "INSERT INTO sf.b_pq_control_point( factory_id , technology_id , oper_date, prod_date , paint_inside_temp , "
        sql &= "paint_inside_damp , primer_temp , topcoat_temp , primer_viscosity , medium_paint_viscosity , topcoat_viscosity , "
        sql &= "primer_plunger_pump_pres , primer_injection_pres , topcoat_plunger_pump_pres , topcoat_injection_pres , prod_in_primer_before_temp , "
        sql &= "prod_out_primer_after_temp , prod_in_topcoat_before_temp , prod_out_topcoat_after_temp , prod_out_topcoat_after_film_thickness,oper, update_time) "
        sql &= "VALUES ( ?, ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , (SELECT CURRENT_TIMESTAMP(6)))"
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .factory_id, .technology_id, .oper_date, .prod_date, .paint_inside_temp,
                                         .paint_inside_damp, .primer_temp, .topcoat_temp, .primer_viscosity, .medium_paint_viscosity, .topcoat_viscosity,
                                         .primer_plunger_pump_pres, .primer_injection_pres, .topcoat_plunger_pump_pres, .topcoat_injection_pres, .prod_in_primer_before_temp,
                                         .prod_out_primer_after_temp, .prod_in_topcoat_before_temp, .prod_out_topcoat_after_temp, .prod_out_topcoat_after_film_thickness, .oper)
        End With
        Return rtn
    End Function

    Public Function update(en As entityControlPoint) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer
        sql &= " UPDATE sf.b_pq_control_point SET oper_date = ? , prod_date = ? , paint_inside_temp = ? , paint_inside_damp = ? "
        sql &= " , primer_temp = ? , topcoat_temp = ?, primer_viscosity = ?, medium_paint_viscosity = ?, topcoat_viscosity = ?, primer_plunger_pump_pres = ? "
        sql &= " , primer_injection_pres = ?,topcoat_plunger_pump_pres = ?,topcoat_injection_pres = ?, prod_in_primer_before_temp = ?, prod_out_primer_after_temp = ? "
        sql &= " , prod_in_topcoat_before_temp = ? , prod_out_topcoat_after_temp = ?, prod_out_topcoat_after_film_thickness = ? , update_time = (SELECT CURRENT_TIMESTAMP(6))"
        sql &= " WHERE sys_id = ? "
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .oper_date, .prod_date, .paint_inside_temp, .paint_inside_damp,
                                         .primer_temp, .topcoat_temp, .primer_viscosity, .medium_paint_viscosity, .topcoat_viscosity,
                                         .primer_plunger_pump_pres, .primer_injection_pres, .topcoat_plunger_pump_pres, .topcoat_injection_pres, .prod_in_primer_before_temp,
                                         .prod_out_primer_after_temp, .prod_in_topcoat_before_temp, .prod_out_topcoat_after_temp, .prod_out_topcoat_after_film_thickness, .sys_id)
        End With
        Return rtn
    End Function

    Public Function selectBySysid(_sysid As String) As DataTable
        Dim szSql As String = "select a.*,b.requirement,b.control_point from sf.b_pq_control_point a left join sf.t_mst_technology b on a.technology_id::integer = b.sys_id where a.factory_id=? and a.sys_id=?"
        Return DBacs.ExecuteSql(szSql, -1, "TS", _sysid)
    End Function

    Public Function getList(startTime As String, endTime As String) As DataTable
        Dim szSql As String = ""
        szSql &= " select * from sf.b_pq_control_point "
        szSql &= " where 1=1 "
        If startTime <> "" Then
            szSql &= " and update_time >= '" + startTime + "'"
        End If
        If endTime <> "" Then
            szSql &= " and update_time <= '" + endTime + "'"
        End If
        Return DBacs.ExecuteSql(szSql, -1)
    End Function

End Class
